package com.sumainfor.pc.epc.service.impl;

import com.qiniu.util.Json;
import com.sumainfor.common.config.RedisUtils;
import com.sumainfor.common.util.ContextUtils;
import com.sumainfor.common.util.InteDeviceBeeConfig;
import com.sumainfor.common.util.InteDeviceBeeUtil;
import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.ParamsCommon;
import com.sumainfor.pc.epc.dao.*;
import com.sumainfor.pc.epc.feign.Zfeign.ZpcMktFeign;
import com.sumainfor.pc.epc.service.HoHousingPlanService;
import com.sumainfor.pc.epc.service.HoHpbService;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.ReentrantLock;

@Service
public class HoHousingPlanServiceImpl implements HoHousingPlanService {
    private ReentrantLock lock = new ReentrantLock(false);//
    Logger log = LoggerFactory.getLogger(HoHousingPlanServiceImpl.class);// 日志
    @Autowired
    private HoHousingPlanMapper hoHousingPlanMapper;
    @Autowired
    private HoHpiMapper hoHpiMapper;
    @Autowired
    private HoHousingAlterInfoMapper hoHousingAlterInfoMapper;
    @Autowired
    private HoHousingAlterMapper hoHousingAlterMapper;
    @Autowired
    private RedisUtils redisUtils;
    /**
     *查询某个房源的房源配置主表
     */
    @Override
    public JsonResult getHoHpList(Map<String, Object> params) {
        JsonResult result=new JsonResult();
        Map<String,Object> resultMap=new HashMap<String,Object>();
        Integer ifCount=0;//是否有未采购完成的房源配置 0 没有 1 有
        if (params.get("HouId")==null){
            return result.putFailed("参数不正确");
        }
        //查询房源配置主表
        List<Map<String,Object>> houList=hoHousingPlanMapper.getHoHpList(params);
        if (houList!=null){
            result.put(houList);
        }else{
            result.putFailed("服务器繁忙");
        }
        //查询房源配置详表
        List<Map<String,Object>> houInfoList=hoHpiMapper.getHoHpiList(params);
        System.out.println("houList:"+houList);
        System.out.println("houInfoList:"+houInfoList);
        for (Map<String,Object> map1:houList){
            List<Map<String,Object>> conList=new ArrayList<Map<String, Object>>();
            if (map1.get("HouCon")!=null){
                for (Map<String,Object> map2:houInfoList){
                    //判断房源配置价格 是否有未null 或者 为0
//                    if (map2.get("ComPrice")==null || new BigDecimal(map2.get("ComPrice").toString()).compareTo(new BigDecimal("0"))==0){
//////                        ifCount=1;
//////                    }

                    if (map2.get("ComPrice")==null || map2.get("ComPrice").toString().equals("")){
                        ifCount=1;
                    }
                    if (map2.get("HouCon")!=null){
                        if (map1.get("HouCon").toString().equals(map2.get("HouCon").toString())){
                            conList.add(map2);
                        }
                    }
                }
            }
            map1.put("conList",conList);
        }
        resultMap.put("houList",houList);
        resultMap.put("ifCount",ifCount);
        return result.put(resultMap);
    }
    /**
     * 工程部修改房源的阁楼 阳台 天窗
     */
    @Transactional(rollbackFor = Exception.class)
    public JsonResult updateHoHouInfoInId(Map<String,Object> params){
        JsonResult result=new JsonResult();
        /**
         * 加锁操作
         */
        lock.lock();
        try{
            try {
                if (params.get("HouConId")==null || params.get("StyleId")==null){
                    return result.putFailed("参数不正确");
                }
                params.put("by", ContextUtils.getUserId());//操作人
                params.put("term", "3");// 更新端 Update端： 1 租客端 2市场部 3 工程部   4运营部   5财务部  6总经办 7发展部
                params.put("fnc",
                        this.getClass().getSimpleName() + "." + Thread.currentThread().getStackTrace()[1].getMethodName());// 创建Function名
                ParamsCommon.commonUpdateParms(params);
                Integer count=hoHousingPlanMapper.updateHoHouInfoInId(params);
                if (count>0){
                    result.putSuccess("操作成功");
                }else{
                    result.putFailed("服务器繁忙");
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                }
            } catch (Exception e) {
                result.putFailed("服务器繁忙");
                e.printStackTrace();
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            }
        }
        finally {
            lock.unlock();
        }
        return result;
    }
    /**
     *市场部房源池的房源详情查询房源的各个房间的房间配置信息
     */
    @Transactional(rollbackFor = Exception.class)
    public JsonResult getHoPlanAlterList(Map<String,Object> params){
        JsonResult result=new JsonResult();
        //查询房源的房源配置主表列表
        List<Map<String,Object>> list=hoHousingPlanMapper.getHoPlanAlterList(params);
        for(Map<String,Object> map:list){
            //HouCount 0 不存在配置变更 1存在配置变更
            if(map.get("HouCount").toString().equals("0")){
                //查询没有配置变更的房源配置详表信息
                List<Map<String,Object>> houConList=hoHpiMapper.getHoHpiCon(map);
                if (houConList!=null){
                    map.put("HciList",houConList);
                }else{
                    map.put("HciList",new ArrayList<Map<String,Object>>());
                }
            }else{
                //审核状态   1.审核中   2被驳回    3审核通过
                List<Map<String,Object>> houConList;
                if (map.get("AuditState")!=null){
                    if (map.get("AuditState").toString().equals("3")){
                        houConList=hoHousingAlterInfoMapper.getHoHpiAlterInfo(map);
                    }else{
                        houConList=hoHpiMapper.getHoHpiCon(map);
                    }
                    if (houConList!=null){
                        map.put("HciList",houConList);
                    }else{
                        map.put("HciList",new ArrayList<Map<String,Object>>());
                    }
                }else{
                    houConList=hoHpiMapper.getHoHpiCon(map);
                }
            }
        }
        if (list!=null){
            result.put(list);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
    /**
     * 租客端协助开门查询房源的房间配置
     */
    public JsonResult getHoInteHouConInfoList(Map<String,Object> params){
        JsonResult result=new JsonResult();
        if (params.get("HouConId")==null || params.get("HouId")==null){
            return result.putFailed("参数不正确");
        }
        List<Map<String,Object>> list=hoHousingPlanMapper.getHoInteHouConInfoList(params);
        System.out.println("list:"+list);
        if (list==null){
            list=new ArrayList<Map<String,Object>>();
        }
        return result.put(list);
    }
    /**
     * 服务秘书审核首月水电押金账单的时候查询房源的智能设备编号列表
     */
    public JsonResult getHoSeInteConList(Map<String,Object> params){
        JsonResult result=new JsonResult();
        //ProOperaType  租赁类型（1.合租 2.整租）
        if (params.get("ProOperaType").toString().equals("2")){
            params.put("IfHouId","1");
        }else if (params.get("ProOperaType").toString().equals("1")){
            params.put("IfHouInfoId","1");
        }
        List<Map<String,Object>> list=hoHousingPlanMapper.getHoSeInteConList(params);
        if (list!=null){
            result.put(list);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result.put(list);
    }
    /**
     * 租客端申请临时密码 （只查询有智能设备的房间）
     */
    public JsonResult getHoRdHouList(Map<String,Object> params){
        JsonResult result=new JsonResult();
        List<Map<String,Object>> list=hoHousingPlanMapper.getHoRdHouList(params);
        if (list!=null){
            result.put(list);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result.put(list);
    }
    /**
     * 租赁顾问签约的时候查询房源的配置列表 房间 or 房源
     */
    public JsonResult getHoRdHouConList(Map<String,Object> params){
        JsonResult result=new JsonResult();
        //保存房间的配置列表
        List<Map<String,Object>> hoHouConList=new ArrayList<Map<String,Object>>();
        //IfOperaType 是否是整租 0否 1是
        if (params.get("IfOperaType").toString().equals("1")){
            //查询房源的 有配置变更 和没有配置变更
            params.put("IfHouId",1);//查询房源
        }else if (params.get("IfOperaType").toString().equals("0")){
            params.put("IfHouConId",1);//查询房源的某个房间
        }
        List<Map<String,Object>> hoPlanList=hoHousingPlanMapper.getHoRdPlanAlterList(params);
        for(Map<String,Object> map:hoPlanList){
            //HouCount 0 不存在配置变更 1存在配置变更
            if(map.get("HouCount").toString().equals("0")){
                //查询没有配置变更的房源配置详表信息
                List<Map<String,Object>> houConList=hoHousingPlanMapper.getHoRdHouConList(map);
                if (houConList!=null){
                    hoHouConList.addAll(houConList);
                }
            }else{
                //审核状态   1.审核中   2被驳回    3审核通过
                List<Map<String,Object>> houConList;
                if (map.get("AuditState")!=null){
                    if (map.get("AuditState").toString().equals("3")){
                        houConList=hoHousingAlterInfoMapper.getHoHpiAlterInfo(map);
                    }else{
                        houConList=hoHousingPlanMapper.getHoRdHouConList(map);
                    }
                    if (houConList!=null){
                        hoHouConList.addAll(houConList);
                    }
                }else{
                    houConList=hoHousingPlanMapper.getHoRdHouConList(map);
                    if (houConList!=null){
                        hoHouConList.addAll(houConList);
                    }
                }
            }
        }
        if (hoHouConList!=null){
            result.put(hoHouConList);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
    /**
     * 租赁顾问签约的时候查询房源的配置列表 公共区域
     */
    public JsonResult getHoRdHouConListPublic(Map<String,Object> params){
        JsonResult result=new JsonResult();
        //保存房间的配置列表
        List<Map<String,Object>> hoHouConList=new ArrayList<Map<String,Object>>();
        params.put("IfHouConType",1);//查询公共区域的房间配置
        List<Map<String,Object>> hoPlanList=hoHousingPlanMapper.getHoRdPlanAlterList(params);
        for(Map<String,Object> map:hoPlanList){
            //HouCount 0 不存在配置变更 1存在配置变更
            if(map.get("HouCount").toString().equals("0")){
                //查询没有配置变更的房源配置详表信息
                List<Map<String,Object>> houConList=hoHousingPlanMapper.getHoRdHouConList(map);
                if (houConList!=null){
                    hoHouConList.addAll(houConList);
                }
            }else{
                //审核状态   1.审核中   2被驳回    3审核通过
                List<Map<String,Object>> houConList;
                if (map.get("AuditState")!=null){
                    if (map.get("AuditState").toString().equals("3")){
                        houConList=hoHousingAlterInfoMapper.getHoHpiAlterInfo(map);
                    }else{
                        houConList=hoHousingPlanMapper.getHoRdHouConList(map);
                    }
                    if (houConList!=null){
                        hoHouConList.addAll(houConList);
                    }
                }else{
                    houConList=hoHousingPlanMapper.getHoRdHouConList(map);
                    if (houConList!=null){
                        hoHouConList.addAll(houConList);
                    }
                }
            }
        }
        if (hoHouConList!=null){
            result.put(hoHouConList);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
    /**
     *市场部服务中心经理定价的房间列表
     */
    @Override
    public JsonResult getHoRdHpiList(Map<String, Object> params) {
        JsonResult result=new JsonResult();
        //查询房间的信息
        List<Map<String,Object>> hoHousingList=hoHousingPlanMapper.getHoRdHpiList(params);
        System.out.println("hoHousingListL:"+hoHousingList);
        //查询房间的配置信息列表
        List<Map<String,Object>> hoHousingConList=hoHpiMapper.getHoRdHpiConList(params);
        System.out.println("hoHousingConList:"+hoHousingConList);
        for (Map<String,Object> map1:hoHousingList){
            List<Map<String,Object>> list=new ArrayList<Map<String, Object>>();
            if (map1.get("PalHouId")!=null){
                for (Map<String,Object> map2:hoHousingConList){
                    if (map2.get("PalHouId")!=null){
                        if (map1.get("PalHouId").toString().equals(map2.get("PalHouId").toString())){
                            list.add(map2);
                        }
                    }
                }
            }
            map1.put("HouConInfoList",list);
        }
        if (hoHousingList!=null){
            result.put(hoHousingList);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
    /**
     *租赁顾问签约的时候查询房源的智能电表or普通电表
     */
    @Override
    public JsonResult getHoRdInteHpiList(Map<String, Object> params) {
        JsonResult result=new JsonResult();
        Map<String,Object> resultMap=new HashMap<String,Object>();
        if (params.get("HouId")==null){
            return  result.putFailed("参数不正确");
        }
        //查询房间的信息
        List<Map<String,Object>> houList=hoHousingPlanMapper.getHoRdInteHpiList(params);
        //保存房间的配置主表编号
        List<String> palHouIdList=new ArrayList<String>();
        for (Map<String,Object> map: houList){
            if(map.get("PalHouId")!=null){
                palHouIdList.add(map.get("PalHouId").toString());
            }
        }
        params.put("palHouIdList",palHouIdList);
        //查询房间的智能设备信息
        int InteCount=0;//记录智能设备的数量()
        String Intelligent="";//保存改房间的智能设备供应商 智能设备供应商     0.蜂电   1.大华   2.科技侠   3.果加
        List<Map<String,Object>> houConList=hoHpiMapper.getHoRdInteHpiConList(params);
        for (Map<String,Object> map1:houList){
            List<Map<String,Object>> list=new ArrayList<Map<String,Object>>();
            if (map1.get("PalHouId")!=null){
                for (Map<String,Object> map2:houConList){
                    if (map2.get("PalHouId")!=null){
                        //Intelligent 智能设备供应商     0.蜂电   1.大华   2.科技侠   3.果加
                        if (map2.get("Intelligent")!=null){
                            Intelligent=map2.get("Intelligent").toString();
                        }
                        if (map1.get("PalHouId").toString().equals(map2.get("PalHouId").toString())){
                            list.add(map2);
                        }
                    }
                }
            }
            if (list.size()>1){//一个房间有两个或两以上的智能电表
                return result.putFailed("房间配置异常（同一个房间的智能电表不唯一）");
            }else  if(list.size()==1){//一个房间的智能电表唯一的时候
                Map<String,Object> map3=list.get(0);
                map1.putAll(map3);
                InteCount++;
            }
        }
        System.out.println("智能电表的数量InteCount:"+InteCount);
        if (InteCount==0 || InteCount==houConList.size()){
            resultMap.put("list",houList);//房间的电表
            resultMap.put("InteCount",InteCount);//房间的智能电表数量
            resultMap.put("Intelligent",Intelligent);//智能设备的供应商
            result.put(resultMap);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }

    /**
     *查询房源的智能门锁
     * @param params
     * @return
     */
    @Override
    public JsonResult getHouRdRoomList(Map<String,Object> params){

        JsonResult result=new JsonResult();
        Map<String,Object> resultMap=new HashMap<String,Object>();
        if (params.get("HouId")==null){
            return  result.putFailed("参数不正确");
        }
        //查询房间的信息
        List<Map<String,Object>> houList=hoHousingPlanMapper.getHoRdInteHpiList(params);
        //保存房间的配置主表编号
        List<String> palHouIdList=new ArrayList<String>();
        for (Map<String,Object> map: houList){
            if(map.get("PalHouId")!=null){
                palHouIdList.add(map.get("PalHouId").toString());
            }
        }
        params.put("palHouIdList",palHouIdList);
        //查询房间的智能设备信息
        int InteCount=0;//记录智能设备的数量()
        String Intelligent="";//保存改房间的智能设备供应商 智能设备供应商     0.蜂电   1.大华   2.科技侠   3.果加
        List<Map<String,Object>> houConList=hoHpiMapper.getHouRdRoomList(params);
        for (Map<String,Object> map1:houList){
            List<Map<String,Object>> list=new ArrayList<Map<String,Object>>();
            if (map1.get("PalHouId")!=null){
                for (Map<String,Object> map2:houConList){
                    if (map2.get("PalHouId")!=null){
                        //Intelligent 智能设备供应商     0.蜂电   1.大华   2.科技侠   3.果加
                        if (map2.get("Intelligent")!=null){
                            Intelligent=map2.get("Intelligent").toString();
                        }
                        if (map1.get("PalHouId").toString().equals(map2.get("PalHouId").toString())){
                            list.add(map2);
                        }
                    }
                }
            }
            if (list.size()>1){//一个房间有两个或两以上的智能门锁
                return result.putFailed("房间配置异常（同一个房间的智能门锁不唯一）");
            }else  if(list.size()==1){//一个房间的智能门锁唯一的时候
                Map<String,Object> map3=list.get(0);
                map1.putAll(map3);
                InteCount++;
            }
        }
        System.out.println("智能门锁的数量InteCount:"+InteCount);
        if (InteCount==0 || InteCount==houConList.size()){
            resultMap.put("list",houList);//房间的门锁
            resultMap.put("InteCount",InteCount);//房间的智能门锁的数量
            resultMap.put("Intelligent",Intelligent);//智能设备的供应商
            result.put(resultMap);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;

    }




















    /**
     *租客端 充值智能设备 查询房源的房间配置列表信息
     */
    public JsonResult getHoRdInteDeviceHouList(Map<String,Object> params){
        JsonResult result=new JsonResult();
        //保存房间的配置列表
        List<Map<String,Object>> hoHouConList=new ArrayList<Map<String,Object>>();
        List<Map<String,Object>> hoPlanList=hoHousingPlanMapper.getHoRdInteDevicePlanAlterList(params);
        //保存没有配置变更的房源编号
        List<String> houIdList=new ArrayList<String>();
        //保存有配置变更的房源编号
        List<String> AlterIdList=new ArrayList<String>();
        //筛选 有配置变更和无配置变更的房间
        for(Map<String,Object> map:hoPlanList){
            //HouCount 0 不存在配置变更 1存在配置变更
            if(map.get("HouCount").toString().equals("0")){
                if (map.get("PalHouId")!=null){
                    houIdList.add(map.get("PalHouId").toString());
                }
            }else{
                //审核状态   1.审核中   2被驳回    3审核通过
                if (map.get("AuditState")!=null){
                    if (map.get("AuditState").toString().equals("3")){
                        if (map.get("AltId")!=null){
                            AlterIdList.add(map.get("AltId").toString());
                        }
                    }else{
                        houIdList.add(map.get("PalHouId").toString());
                    }
                }
            }
        }
        //无配置变更的房源编号集合
        params.put("houIdList",houIdList);
        //有配置变更的房源编号集合
        params.put("AlterIdList",AlterIdList);
        List<Map<String,Object>>  InteDeviceHouList=hoHousingPlanMapper.getHoRdInteDeviceHouList(params);
        List<Map<String,Object>> AlterInteDeviceiList=hoHousingAlterMapper.getHoAlterInteDeviceiList(params);
        if (InteDeviceHouList!=null){
            hoHouConList.addAll(InteDeviceHouList);
        }
        if (AlterInteDeviceiList!=null){
            hoHouConList.addAll(AlterInteDeviceiList);
        }
        if (hoHouConList!=null){
            result.put(hoHouConList);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
    /**
     * 退租的时候查询房源的房间智能电表信息列表
     */
    @Override
    public JsonResult getHoRdInteDeviceList(Map<String, Object> params) {
        System.out.println("params:"+params);
        JsonResult result=new JsonResult();
        Map<String,Object> resultMap=new HashMap<String, Object>();
        if (params.get("ProOperaType")==null || params.get("HouConId")==null || params.get("HouId")==null){
            return result.putFailed("参数不正确");
        }
        //保存房间的配置列表
        List<Map<String,Object>> hoHouConList=new ArrayList<Map<String,Object>>();
        List<Map<String,Object>> hoPlanList=hoHousingPlanMapper.getHoRdInteDeviceList(params);
        //保存没有配置变更的房源编号
        List<String> palHouIdList=new ArrayList<String>();
        //保存有配置变更的房源编号
        List<String> AlterIdList=new ArrayList<String>();
        //筛选 有配置变更和无配置变更的房间
        for(Map<String,Object> map:hoPlanList){
            //HouCount 0 不存在配置变更 1存在配置变更
            if(map.get("HouCount").toString().equals("0")){
                if (map.get("PalHouId")!=null){
                    System.out.println("1");
                    palHouIdList.add(String.valueOf(map.get("PalHouId")));
                }
            }else{
                //审核状态   1.审核中   2被驳回    3审核通过
                if (map.get("AuditState")!=null){
                    if (map.get("AuditState").toString().equals("3")){
                        if (map.get("AltId")!=null){
                            System.out.println("1");
                            AlterIdList.add(String.valueOf(map.get("AltId")));
                        }
                    }else{
                        System.out.println("1");
                        palHouIdList.add(String.valueOf(map.get("PalHouId")));
                    }
                }
            }
        }
        //无配置变更的房源编号集合
        params.put("palHouIdList",palHouIdList);
        //有配置变更的房源编号集合
        params.put("AlterIdList",AlterIdList);
        System.out.println("拼装后的参数:"+params);
        if (palHouIdList.size()>0){
            List<Map<String,Object>>  InteDeviceHouList=hoHpiMapper.getHoRdInteHpiConList(params);
            if (InteDeviceHouList!=null){
                hoHouConList.addAll(InteDeviceHouList);
            }
        }
        if (AlterIdList.size()>0) {
            List<Map<String,Object>> AlterInteDeviceiList=hoHousingAlterMapper.getHoAlterInteDeviceiList(params);
            if (AlterInteDeviceiList!=null){
                hoHouConList.addAll(AlterInteDeviceiList);
            }
        }
        //蜂电智能电表的设备编号（用来获取蜂电智能设备编号的UUID，后面请求退租、修改付费模式的接口要用这个编号）
        List<String> inteIdList=new ArrayList<String>();
        //智能设备供应商     0.蜂电   1.大华   2.科技侠   3.果加
        String ifIntelligentDevice="";
        System.out.println("hoHouConList:"+hoHouConList);
        for (Map<String,Object> map:hoHouConList){
            if (map.get("Intelligent")!=null ){
                ifIntelligentDevice=map.get("Intelligent").toString();
                System.out.println("map.get(\"Intelligent\"):"+map.get("Intelligent"));
                if (map.get("Intelligent")!=null && map.get("Intelligent").toString().equals("0")){
                    inteIdList.add(String.valueOf(map.get("Identifier")));
                }
            }
        }
        System.out.println("智能电表的数组:"+hoHouConList);
        System.out.println("ifIntelligentDevice:"+ifIntelligentDevice);
        System.out.println("inteIdList:"+inteIdList);
        //如果是蜂电的智能电表就要查询一下智能电表的设备的编号的UUID
        if (inteIdList.size()>0){
            String InteDeviceBeeToken=redisUtils.get("InteDeviceBeeToken");
            //如果获取不到就重新登录
            if (InteDeviceBeeToken==null) {
                Map<String, Object> tokenMap = new HashMap<String, Object>();
                params.put("version","0116010101");//版本号 默认 0116010101
                params.put("appid", InteDeviceBeeConfig.APP_ID);
                tokenMap= InteDeviceBeeUtil.userLogin(InteDeviceBeeConfig.USERID, InteDeviceBeeConfig.PASS,params);
                if (tokenMap.get("Code").toString().equals("0")) {
                    InteDeviceBeeToken = tokenMap.get("Expand").toString();
                    //token存到redis中 有效时长一个小时
                    redisUtils.set("InteDeviceBeeToken", InteDeviceBeeToken,3600);
                } else {
                    return result.putFailed("token获取失败");
                }
            }
            Map<String,Object> pcodeParams=new HashMap<String, Object>();
            pcodeParams.put("uid",InteDeviceBeeConfig.UID);
            pcodeParams.put("token",InteDeviceBeeToken);
            //获取蜂电智能设备的UUID集合
            Map<String,Object> pcodeMap=InteDeviceBeeUtil.deviceAmmeterPcode(inteIdList,pcodeParams);
            List<Map<String,Object>> pcodeList=(List<Map<String,Object>>)pcodeMap.get("Data");
            for (Map<String,Object> map1:hoHouConList){
                if (map1.get("Identifier")!=null){
                    for (Map<String,Object> map2:pcodeList){
                        if (map2.get("Pcode")!=null){
                            if (map1.get("Identifier").toString().equals(map2.get("Pcode").toString())){
                                map1.put("Uuid",map2.get("Uuid"));
                            }
                        }
                    }
                }
            }
        }
        resultMap.put("ifIntelligentDevice",ifIntelligentDevice);
        resultMap.put("hoHouConList",hoHouConList);
        return result.put(resultMap);
    }
    /**
     * 租赁顾问点击确认到达的时候查询房源的智能门锁编号信息
     */
    @Override
    public JsonResult getHoRdWorder(Map<String, Object> params) {
        System.out.println("getHoRdWorder:"+params);
        JsonResult result=new JsonResult();
        //查询房源的房源配置主表列表
        List<Map<String,Object>> list=hoHousingPlanMapper.getHoRdWorder(params);
        List<Map<String,Object>> resultList=new ArrayList<Map<String,Object>>();
        for(Map<String,Object> map:list){
            List<Map<String,Object>> houConList=new ArrayList<Map<String,Object>>();
            // IfLockOrEte  1查询门锁  2查电表
            map.put("IfLockOrEte",params.get("IfLockOrEte"));
            //HouCount 0 不存在配置变更 1存在配置变更
            if(map.get("HouCount").toString().equals("0")){
                //查询没有配置变更的房源配置详表信息
                houConList=hoHpiMapper.getHoHpiCon(map);
            }else{
                //审核状态   1.审核中   2被驳回    3审核通过
                if (map.get("AuditState")!=null){
                    houConList=map.get("AuditState").toString().equals("3")?hoHousingAlterInfoMapper.getHoHpiAlterInfo(map):hoHpiMapper.getHoHpiCon(map);
                }else{
                    houConList=hoHpiMapper.getHoHpiCon(map);
                }
            }
            if (houConList!=null){
                resultList.addAll(houConList);
            }
        }
        return result.put(resultList);
    }
}
